package cn.iocoder.yudao.module.promotion.controller.app.prizedraw;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.PrizeDrawNumberMemberDO;
import cn.iocoder.yudao.module.promotion.service.prizedraw.PrizeDrawNumberMemberService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;


@Tag(name = "用户 APP - 用户抽奖次数")
@RestController
@RequestMapping("/promotion/prize-draw-number-member")
@Validated
public class AppPrizeDrawNumberMemberController {
    @Resource
    private PrizeDrawNumberMemberService prizeDrawNumberMemberService;

    @Operation(summary ="用户抽奖次数")
    @GetMapping("/getUserPrizeNum")
    public CommonResult<Integer> getUserPrizeNum() {
        PrizeDrawNumberMemberDO motoPrizeDrawNumberMember = prizeDrawNumberMemberService.getByMemberId(getLoginUserId());
        Integer number=motoPrizeDrawNumberMember == null ? 0 : motoPrizeDrawNumberMember.getDrawNumber();
        return success(number);
    }

}
